---
title: WebView
description: A library that provides a WebView component.
sourceCodeUrl: 'https://github.com/react-native-webview/react-native-webview'
packageName: 'react-native-webview'
---

import { APIInstallSection } from '~/components/plugins/InstallSection';
import PlatformsSection from '~/components/plugins/PlatformsSection';
import { SnackInline } from '~/ui/components/Snippet';

`react-native-webview` provides a `WebView` component that renders web content in a native view.

<PlatformsSection android emulator ios simulator />

## Installation

<APIInstallSection href="https://github.com/react-native-webview/react-native-webview/blob/master/docs/Getting-Started.md#react-native-webview-getting-started-guide" />

## Usage

You should refer to the [`react-native-webview` documentation](https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md#react-native-webview-guide) for more information on the API and its usage. The following example (courtesy of that repository) is a quick way to get up and running!

<SnackInline label="Basic Webview usage" dependencies={["react-native-webview", "expo-constants"]}>

{/* prettier-ignore */}
```jsx
import * as React from 'react';
import { WebView } from 'react-native-webview';
/* @hide */
import { StyleSheet } from 'react-native';
import Constants from 'expo-constants';
/* @end */

export default function App() {
  return (
    <WebView
      style={styles.container}
      source={{ uri: 'https://expo.dev' }}
    />
  );
}


const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: Constants.statusBarHeight,
  },
});

```

</SnackInline>

Minimal example with inline HTML:

<SnackInline label="Webview inline HTML" dependencies={["react-native-webview", "expo-constants"]}>

```jsx
import * as React from 'react';
import { WebView } from 'react-native-webview';
/* @hide */
import { StyleSheet } from 'react-native';
import Constants from 'expo-constants';
/* @end */

export default function App() {
  return (
    <WebView
      style={styles.container}
      originWhitelist={['*']}
      source={{ html: '<h1><center>Hello world</center></h1>' }}
    />
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: Constants.statusBarHeight,
  },
});
```

</SnackInline>
